package com.three.controller;

import com.baor.baseUtil.R;
import com.three.domain.Subjects;
import com.three.service.SubjectsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class SubjectsController {
    @Autowired
    private SubjectsService subjectsService;

    @RequestMapping(value="/subjectsList")
    public R subjectsList(@RequestBody Map<String, Object> map) {
        String keyword = (String) map.get("keyword");
        Integer pageIndex = (Integer) map.get("pageIndex");
        Integer pageSize = (Integer) map.get("pageSize");
        return subjectsService.subjectsList(pageIndex,pageSize,keyword);
    }

    @RequestMapping(value="/addSubjects")
    public R addSubjects(@RequestBody Subjects subjects) {
        return subjectsService.addSubjects(subjects);
    }

    @RequestMapping(value="/updateSubjects")
    public R updateSubjects(@RequestBody Subjects subjects) {
        return subjectsService.updateSubjects(subjects);
    }

    @RequestMapping(value="/deleteSubjects")
    public R deleteSubjects(@RequestBody Subjects subjects) {
        return subjectsService.deleteSubjects(subjects.getSubject_id());
    }
}
